home *** CD-ROM | disk | FTP | other *** search
/ Kellogg's Amérique / Kellogg's Amérique / main.swf / scripts / fl / controls / ComboBox.as < prev    next >
Text File  |  2020-08-04  |  26KB  |  875 lines

  1. package fl.controls
  2. {
  3.    import fl.controls.listClasses.ICellRenderer;
  4.    import fl.core.InvalidationType;
  5.    import fl.core.UIComponent;
  6.    import fl.data.DataProvider;
  7.    import fl.data.SimpleCollectionItem;
  8.    import fl.events.ComponentEvent;
  9.    import fl.events.DataChangeEvent;
  10.    import fl.events.ListEvent;
  11.    import fl.managers.IFocusManagerComponent;
  12.    import flash.display.DisplayObject;
  13.    import flash.events.Event;
  14.    import flash.events.FocusEvent;
  15.    import flash.events.KeyboardEvent;
  16.    import flash.events.MouseEvent;
  17.    import flash.geom.Point;
  18.    import flash.text.TextFormat;
  19.    import flash.ui.Keyboard;
  20.    
  21.    public class ComboBox extends UIComponent implements IFocusManagerComponent
  22.    {
  23.       
  24.       private static var defaultStyles:Object = {
  25.          "upSkin":"ComboBox_upSkin",
  26.          "downSkin":"ComboBox_downSkin",
  27.          "overSkin":"ComboBox_overSkin",
  28.          "disabledSkin":"ComboBox_disabledSkin",
  29.          "focusRectSkin":null,
  30.          "focusRectPadding":null,
  31.          "textFormat":null,
  32.          "disabledTextFormat":null,
  33.          "textPadding":3,
  34.          "buttonWidth":24,
  35.          "disabledAlpha":null,
  36.          "listSkin":null
  37.       };
  38.       
  39.       public static var createAccessibilityImplementation:Function;
  40.       
  41.       protected static const BACKGROUND_STYLES:Object = {
  42.          "overSkin":"overSkin",
  43.          "downSkin":"downSkin",
  44.          "upSkin":"upSkin",
  45.          "disabledSkin":"disabledSkin",
  46.          "repeatInterval":"repeatInterval"
  47.       };
  48.       
  49.       protected static const LIST_STYLES:Object = {
  50.          "upSkin":"comboListUpSkin",
  51.          "overSkin":"comboListOverSkin",
  52.          "downSkin":"comobListDownSkin",
  53.          "disabledSkin":"comboListDisabledSkin",
  54.          "downArrowDisabledSkin":"downArrowDisabledSkin",
  55.          "downArrowDownSkin":"downArrowDownSkin",
  56.          "downArrowOverSkin":"downArrowOverSkin",
  57.          "downArrowUpSkin":"downArrowUpSkin",
  58.          "upArrowDisabledSkin":"upArrowDisabledSkin",
  59.          "upArrowDownSkin":"upArrowDownSkin",
  60.          "upArrowOverSkin":"upArrowOverSkin",
  61.          "upArrowUpSkin":"upArrowUpSkin",
  62.          "thumbDisabledSkin":"thumbDisabledSkin",
  63.          "thumbDownSkin":"thumbDownSkin",
  64.          "thumbOverSkin":"thumbOverSkin",
  65.          "thumbUpSkin":"thumbUpSkin",
  66.          "thumbIcon":"thumbIcon",
  67.          "trackDisabledSkin":"trackDisabledSkin",
  68.          "trackDownSkin":"trackDownSkin",
  69.          "trackOverSkin":"trackOverSkin",
  70.          "trackUpSkin":"trackUpSkin",
  71.          "repeatDelay":"repeatDelay",
  72.          "repeatInterval":"repeatInterval",
  73.          "textFormat":"textFormat",
  74.          "disabledAlpha":"disabledAlpha",
  75.          "skin":"listSkin"
  76.       };
  77.        
  78.       
  79.       protected var _dropdownWidth:Number;
  80.       
  81.       protected var highlightedCell:int = -1;
  82.       
  83.       protected var _prompt:String;
  84.       
  85.       protected var isOpen:Boolean = false;
  86.       
  87.       protected var list:List;
  88.       
  89.       protected var _rowCount:uint = 5;
  90.       
  91.       protected var currentIndex:int;
  92.       
  93.       protected var isKeyDown:Boolean = false;
  94.       
  95.       protected var _labels:Array;
  96.       
  97.       protected var background:BaseButton;
  98.       
  99.       protected var inputField:TextInput;
  100.       
  101.       protected var listOverIndex:uint;
  102.       
  103.       protected var editableValue:String;
  104.       
  105.       protected var _editable:Boolean = false;
  106.       
  107.       private var collectionItemImport:SimpleCollectionItem;
  108.       
  109.       public function ComboBox()
  110.       {
  111.          _rowCount = 5;
  112.          _editable = false;
  113.          isOpen = false;
  114.          highlightedCell = -1;
  115.          isKeyDown = false;
  116.          super();
  117.       }
  118.       
  119.       public static function getStyleDefinition() : Object
  120.       {
  121.          return mergeStyles(defaultStyles,List.getStyleDefinition());
  122.       }
  123.       
  124.       protected function drawList() : void
  125.       {
  126.          list.rowCount = Math.max(0,Math.min(_rowCount,list.dataProvider.length));
  127.       }
  128.       
  129.       public function set imeMode(param1:String) : void
  130.       {
  131.          inputField.imeMode = param1;
  132.       }
  133.       
  134.       public function get dropdown() : List
  135.       {
  136.          return list;
  137.       }
  138.       
  139.       public function get dropdownWidth() : Number
  140.       {
  141.          return list.width;
  142.       }
  143.       
  144.       public function sortItemsOn(param1:String, param2:Object = null) : *
  145.       {
  146.          return list.sortItemsOn(param1,param2);
  147.       }
  148.       
  149.       protected function onEnter(param1:ComponentEvent) : void
  150.       {
  151.          param1.stopPropagation();
  152.       }
  153.       
  154.       public function removeItemAt(param1:uint) : void
  155.       {
  156.          list.removeItemAt(param1);
  157.          invalidate(InvalidationType.DATA);
  158.       }
  159.       
  160.       public function open() : void
  161.       {
  162.          currentIndex = selectedIndex;
  163.          if(isOpen || length == 0)
  164.          {
  165.             return;
  166.          }
  167.          dispatchEvent(new Event(Event.OPEN));
  168.          isOpen = true;
  169.          addEventListener(Event.ENTER_FRAME,addCloseListener,false,0,true);
  170.          positionList();
  171.          list.scrollToSelected();
  172.          stage.addChild(list);
  173.       }
  174.       
  175.       public function get selectedItem() : Object
  176.       {
  177.          return list.selectedItem;
  178.       }
  179.       
  180.       public function set text(param1:String) : void
  181.       {
  182.          if(!editable)
  183.          {
  184.             return;
  185.          }
  186.          inputField.text = param1;
  187.       }
  188.       
  189.       public function get labelField() : String
  190.       {
  191.          return list.labelField;
  192.       }
  193.       
  194.       override protected function keyDownHandler(param1:KeyboardEvent) : void
  195.       {
  196.          var _loc2_:int = 0;
  197.          var _loc3_:uint = 0;
  198.          var _loc4_:Number = NaN;
  199.          var _loc5_:int = 0;
  200.          isKeyDown = true;
  201.          if(param1.ctrlKey)
  202.          {
  203.             switch(param1.keyCode)
  204.             {
  205.                case Keyboard.UP:
  206.                   if(highlightedCell > -1)
  207.                   {
  208.                      selectedIndex = highlightedCell;
  209.                      dispatchEvent(new Event(Event.CHANGE));
  210.                   }
  211.                   close();
  212.                   break;
  213.                case Keyboard.DOWN:
  214.                   open();
  215.             }
  216.             return;
  217.          }
  218.          param1.stopPropagation();
  219.          _loc2_ = Math.max(calculateAvailableHeight() / list.rowHeight << 0,1);
  220.          _loc3_ = selectedIndex;
  221.          _loc4_ = highlightedCell == -1 ? Number(selectedIndex) : Number(highlightedCell);
  222.          _loc5_ = -1;
  223.          switch(param1.keyCode)
  224.          {
  225.             case Keyboard.SPACE:
  226.                if(isOpen)
  227.                {
  228.                   close();
  229.                }
  230.                else
  231.                {
  232.                   open();
  233.                }
  234.                return;
  235.             case Keyboard.ESCAPE:
  236.                if(isOpen)
  237.                {
  238.                   if(highlightedCell > -1)
  239.                   {
  240.                      selectedIndex = selectedIndex;
  241.                   }
  242.                   close();
  243.                }
  244.                return;
  245.             case Keyboard.UP:
  246.                _loc5_ = Math.max(0,_loc4_ - 1);
  247.                break;
  248.             case Keyboard.DOWN:
  249.                _loc5_ = Math.min(length - 1,_loc4_ + 1);
  250.                break;
  251.             case Keyboard.PAGE_UP:
  252.                _loc5_ = Math.max(_loc4_ - _loc2_,0);
  253.                break;
  254.             case Keyboard.PAGE_DOWN:
  255.                _loc5_ = Math.min(_loc4_ + _loc2_,length - 1);
  256.                break;
  257.             case Keyboard.HOME:
  258.                _loc5_ = 0;
  259.                break;
  260.             case Keyboard.END:
  261.                _loc5_ = length - 1;
  262.                break;
  263.             case Keyboard.ENTER:
  264.                if(_editable && highlightedCell == -1)
  265.                {
  266.                   editableValue = inputField.text;
  267.                   selectedIndex = -1;
  268.                }
  269.                else if(isOpen && highlightedCell > -1)
  270.                {
  271.                   editableValue = null;
  272.                   selectedIndex = highlightedCell;
  273.                   dispatchEvent(new Event(Event.CHANGE));
  274.                }
  275.                dispatchEvent(new ComponentEvent(ComponentEvent.ENTER));
  276.                close();
  277.                return;
  278.             default:
  279.                if(editable)
  280.                {
  281.                   break;
  282.                }
  283.                _loc5_ = list.getNextIndexAtLetter(String.fromCharCode(param1.keyCode),_loc4_);
  284.                break;
  285.          }
  286.          if(_loc5_ > -1)
  287.          {
  288.             if(isOpen)
  289.             {
  290.                highlightCell(_loc5_);
  291.                inputField.text = list.itemToLabel(getItemAt(_loc5_));
  292.             }
  293.             else
  294.             {
  295.                highlightCell();
  296.                selectedIndex = _loc5_;
  297.                dispatchEvent(new Event(Event.CHANGE));
  298.             }
  299.          }
  300.       }
  301.       
  302.       public function set dropdownWidth(param1:Number) : void
  303.       {
  304.          _dropdownWidth = param1;
  305.          invalidate(InvalidationType.SIZE);
  306.       }
  307.       
  308.       public function get editable() : Boolean
  309.       {
  310.          return _editable;
  311.       }
  312.       
  313.       override protected function focusInHandler(param1:FocusEvent) : void
  314.       {
  315.          super.focusInHandler(param1);
  316.          if(editable)
  317.          {
  318.             stage.focus = inputField.textField;
  319.          }
  320.       }
  321.       
  322.       protected function onStageClick(param1:MouseEvent) : void
  323.       {
  324.          if(!isOpen)
  325.          {
  326.             return;
  327.          }
  328.          if(!contains(param1.target as DisplayObject) && !list.contains(param1.target as DisplayObject))
  329.          {
  330.             if(highlightedCell != -1)
  331.             {
  332.                selectedIndex = highlightedCell;
  333.                dispatchEvent(new Event(Event.CHANGE));
  334.             }
  335.             close();
  336.          }
  337.       }
  338.       
  339.       protected function handleDataChange(param1:DataChangeEvent) : void
  340.       {
  341.          invalidate(InvalidationType.DATA);
  342.       }
  343.       
  344.       override protected function keyUpHandler(param1:KeyboardEvent) : void
  345.       {
  346.          isKeyDown = false;
  347.       }
  348.       
  349.       protected function onListItemUp(param1:MouseEvent) : void
  350.       {
  351.          var _loc2_:* = undefined;
  352.          stage.removeEventListener(MouseEvent.MOUSE_UP,onListItemUp);
  353.          if(!(param1.target is ICellRenderer) || !list.contains(param1.target as DisplayObject))
  354.          {
  355.             return;
  356.          }
  357.          editableValue = null;
  358.          _loc2_ = selectedIndex;
  359.          selectedIndex = param1.target.listData.index;
  360.          if(_loc2_ != selectedIndex)
  361.          {
  362.             dispatchEvent(new Event(Event.CHANGE));
  363.          }
  364.          close();
  365.       }
  366.       
  367.       public function removeAll() : void
  368.       {
  369.          list.removeAll();
  370.          inputField.text = "";
  371.          invalidate(InvalidationType.DATA);
  372.       }
  373.       
  374.       public function set selectedItem(param1:Object) : void
  375.       {
  376.          list.selectedItem = param1;
  377.          invalidate(InvalidationType.SELECTED);
  378.       }
  379.       
  380.       protected function highlightCell(param1:int = -1) : void
  381.       {
  382.          var _loc2_:ICellRenderer = null;
  383.          if(highlightedCell > -1)
  384.          {
  385.             _loc2_ = list.itemToCellRenderer(getItemAt(highlightedCell));
  386.             if(_loc2_ != null)
  387.             {
  388.                _loc2_.setMouseState("up");
  389.             }
  390.          }
  391.          if(param1 == -1)
  392.          {
  393.             return;
  394.          }
  395.          list.scrollToIndex(param1);
  396.          list.drawNow();
  397.          _loc2_ = list.itemToCellRenderer(getItemAt(param1));
  398.          if(_loc2_ != null)
  399.          {
  400.             _loc2_.setMouseState("over");
  401.             highlightedCell = param1;
  402.          }
  403.       }
  404.       
  405.       public function itemToLabel(param1:Object) : String
  406.       {
  407.          if(param1 == null)
  408.          {
  409.             return "";
  410.          }
  411.          return list.itemToLabel(param1);
  412.       }
  413.       
  414.       public function addItemAt(param1:Object, param2:uint) : void
  415.       {
  416.          list.addItemAt(param1,param2);
  417.          invalidate(InvalidationType.DATA);
  418.       }
  419.       
  420.       public function replaceItemAt(param1:Object, param2:uint) : Object
  421.       {
  422.          return list.replaceItemAt(param1,param2);
  423.       }
  424.       
  425.       protected function showPrompt() : void
  426.       {
  427.          inputField.text = _prompt;
  428.       }
  429.       
  430.       public function set rowCount(param1:uint) : void
  431.       {
  432.          _rowCount = param1;
  433.          invalidate(InvalidationType.SIZE);
  434.       }
  435.       
  436.       public function get restrict() : String
  437.       {
  438.          return inputField.restrict;
  439.       }
  440.       
  441.       protected function setEmbedFonts() : void
  442.       {
  443.          var _loc1_:Object = null;
  444.          _loc1_ = getStyleValue("embedFonts");
  445.          if(_loc1_ != null)
  446.          {
  447.             inputField.textField.embedFonts = _loc1_;
  448.          }
  449.       }
  450.       
  451.       public function sortItems(... rest) : *
  452.       {
  453.          return list.sortItems.apply(list,rest);
  454.       }
  455.       
  456.       public function set labelField(param1:String) : void
  457.       {
  458.          list.labelField = param1;
  459.          invalidate(InvalidationType.DATA);
  460.       }
  461.       
  462.       public function set editable(param1:Boolean) : void
  463.       {
  464.          _editable = param1;
  465.          drawTextField();
  466.       }
  467.       
  468.       public function set prompt(param1:String) : void
  469.       {
  470.          if(param1 == "")
  471.          {
  472.             _prompt = null;
  473.          }
  474.          else
  475.          {
  476.             _prompt = param1;
  477.          }
  478.          invalidate(InvalidationType.STATE);
  479.       }
  480.       
  481.       public function get length() : int
  482.       {
  483.          return list.length;
  484.       }
  485.       
  486.       protected function drawTextField() : void
  487.       {
  488.          inputField.setStyle("upSkin","");
  489.          inputField.setStyle("disabledSkin","");
  490.          inputField.enabled = enabled;
  491.          inputField.editable = _editable;
  492.          inputField.textField.selectable = enabled && _editable;
  493.          inputField.mouseEnabled = inputField.mouseChildren = enabled && _editable;
  494.          inputField.focusEnabled = false;
  495.          if(_editable)
  496.          {
  497.             inputField.addEventListener(FocusEvent.FOCUS_IN,onInputFieldFocus,false,0,true);
  498.             inputField.addEventListener(FocusEvent.FOCUS_OUT,onInputFieldFocusOut,false,0,true);
  499.          }
  500.          else
  501.          {
  502.             inputField.removeEventListener(FocusEvent.FOCUS_IN,onInputFieldFocus);
  503.             inputField.removeEventListener(FocusEvent.FOCUS_OUT,onInputFieldFocusOut);
  504.          }
  505.       }
  506.       
  507.       protected function onInputFieldFocusOut(param1:FocusEvent) : void
  508.       {
  509.          inputField.removeEventListener(ComponentEvent.ENTER,onEnter);
  510.          selectedIndex = selectedIndex;
  511.       }
  512.       
  513.       protected function passEvent(param1:Event) : void
  514.       {
  515.          dispatchEvent(param1);
  516.       }
  517.       
  518.       public function get imeMode() : String
  519.       {
  520.          return inputField.imeMode;
  521.       }
  522.       
  523.       public function get labelFunction() : Function
  524.       {
  525.          return list.labelFunction;
  526.       }
  527.       
  528.       protected function calculateAvailableHeight() : Number
  529.       {
  530.          var _loc1_:Number = NaN;
  531.          _loc1_ = Number(getStyleValue("contentPadding"));
  532.          return list.height - _loc1_ * 2;
  533.       }
  534.       
  535.       public function get selectedIndex() : int
  536.       {
  537.          return list.selectedIndex;
  538.       }
  539.       
  540.       override protected function focusOutHandler(param1:FocusEvent) : void
  541.       {
  542.          isKeyDown = false;
  543.          if(isOpen)
  544.          {
  545.             if(!param1.relatedObject || !list.contains(param1.relatedObject))
  546.             {
  547.                if(highlightedCell != -1 && highlightedCell != selectedIndex)
  548.                {
  549.                   selectedIndex = highlightedCell;
  550.                   dispatchEvent(new Event(Event.CHANGE));
  551.                }
  552.                close();
  553.             }
  554.          }
  555.          super.focusOutHandler(param1);
  556.       }
  557.       
  558.       public function get selectedLabel() : String
  559.       {
  560.          if(editableValue != null)
  561.          {
  562.             return editableValue;
  563.          }
  564.          if(selectedIndex == -1)
  565.          {
  566.             return null;
  567.          }
  568.          return itemToLabel(selectedItem);
  569.       }
  570.       
  571.       public function get text() : String
  572.       {
  573.          return inputField.text;
  574.       }
  575.       
  576.       protected function onListChange(param1:Event) : void
  577.       {
  578.          editableValue = null;
  579.          dispatchEvent(param1);
  580.          invalidate(InvalidationType.SELECTED);
  581.          if(isKeyDown)
  582.          {
  583.             return;
  584.          }
  585.          close();
  586.       }
  587.       
  588.       protected function onToggleListVisibility(param1:MouseEvent) : void
  589.       {
  590.          param1.stopPropagation();
  591.          dispatchEvent(param1);
  592.          if(isOpen)
  593.          {
  594.             close();
  595.          }
  596.          else
  597.          {
  598.             open();
  599.             stage.addEventListener(MouseEvent.MOUSE_UP,onListItemUp,false,0,true);
  600.          }
  601.       }
  602.       
  603.       override protected function draw() : void
  604.       {
  605.          var _loc1_:* = undefined;
  606.          _loc1_ = selectedIndex;
  607.          if(_loc1_ == -1 && (prompt != null || editable || length == 0))
  608.          {
  609.             _loc1_ = Math.max(-1,Math.min(_loc1_,length - 1));
  610.          }
  611.          else
  612.          {
  613.             editableValue = null;
  614.             _loc1_ = Math.max(0,Math.min(_loc1_,length - 1));
  615.          }
  616.          if(list.selectedIndex != _loc1_)
  617.          {
  618.             list.selectedIndex = _loc1_;
  619.             invalidate(InvalidationType.SELECTED,false);
  620.          }
  621.          if(isInvalid(InvalidationType.STYLES))
  622.          {
  623.             setStyles();
  624.             setEmbedFonts();
  625.             invalidate(InvalidationType.SIZE,false);
  626.          }
  627.          if(isInvalid(InvalidationType.SIZE,InvalidationType.DATA,InvalidationType.STATE))
  628.          {
  629.             drawTextFormat();
  630.             drawLayout();
  631.             invalidate(InvalidationType.DATA);
  632.          }
  633.          if(isInvalid(InvalidationType.DATA))
  634.          {
  635.             drawList();
  636.             invalidate(InvalidationType.SELECTED,true);
  637.          }
  638.          if(isInvalid(InvalidationType.SELECTED))
  639.          {
  640.             if(_loc1_ == -1 && editableValue != null)
  641.             {
  642.                inputField.text = editableValue;
  643.             }
  644.             else if(_loc1_ > -1)
  645.             {
  646.                if(length > 0)
  647.                {
  648.                   inputField.horizontalScrollPosition = 0;
  649.                   inputField.text = itemToLabel(list.selectedItem);
  650.                }
  651.             }
  652.             else if(_loc1_ == -1 && _prompt != null)
  653.             {
  654.                showPrompt();
  655.             }
  656.             else
  657.             {
  658.                inputField.text = "";
  659.             }
  660.             if(editable && selectedIndex > -1 && stage.focus == inputField.textField)
  661.             {
  662.                inputField.setSelection(0,inputField.length);
  663.             }
  664.          }
  665.          drawTextField();
  666.          super.draw();
  667.       }
  668.       
  669.       public function addItem(param1:Object) : void
  670.       {
  671.          list.addItem(param1);
  672.          invalidate(InvalidationType.DATA);
  673.       }
  674.       
  675.       public function get rowCount() : uint
  676.       {
  677.          return _rowCount;
  678.       }
  679.       
  680.       override protected function configUI() : void
  681.       {
  682.          super.configUI();
  683.          background = new BaseButton();
  684.          background.focusEnabled = false;
  685.          copyStylesToChild(background,BACKGROUND_STYLES);
  686.          background.addEventListener(MouseEvent.MOUSE_DOWN,onToggleListVisibility,false,0,true);
  687.          addChild(background);
  688.          inputField = new TextInput();
  689.          inputField.focusTarget = this as IFocusManagerComponent;
  690.          inputField.focusEnabled = false;
  691.          inputField.addEventListener(Event.CHANGE,onTextInput,false,0,true);
  692.          addChild(inputField);
  693.          list = new List();
  694.          list.focusEnabled = false;
  695.          copyStylesToChild(list,LIST_STYLES);
  696.          list.addEventListener(Event.CHANGE,onListChange,false,0,true);
  697.          list.addEventListener(ListEvent.ITEM_CLICK,onListChange,false,0,true);
  698.          list.addEventListener(ListEvent.ITEM_ROLL_OUT,passEvent,false,0,true);
  699.          list.addEventListener(ListEvent.ITEM_ROLL_OVER,passEvent,false,0,true);
  700.          list.verticalScrollBar.addEventListener(Event.SCROLL,passEvent,false,0,true);
  701.       }
  702.       
  703.       protected function positionList() : void
  704.       {
  705.          var _loc1_:Point = null;
  706.          _loc1_ = localToGlobal(new Point(0,0));
  707.          list.x = _loc1_.x;
  708.          if(_loc1_.y + height + list.height > stage.stageHeight)
  709.          {
  710.             list.y = _loc1_.y - list.height;
  711.          }
  712.          else
  713.          {
  714.             list.y = _loc1_.y + height;
  715.          }
  716.       }
  717.       
  718.       public function get value() : String
  719.       {
  720.          var _loc1_:Object = null;
  721.          if(editableValue != null)
  722.          {
  723.             return editableValue;
  724.          }
  725.          _loc1_ = selectedItem;
  726.          if(!_editable && _loc1_.data != null)
  727.          {
  728.             return _loc1_.data;
  729.          }
  730.          return itemToLabel(_loc1_);
  731.       }
  732.       
  733.       public function get prompt() : String
  734.       {
  735.          return _prompt;
  736.       }
  737.       
  738.       public function set dataProvider(param1:DataProvider) : void
  739.       {
  740.          param1.addEventListener(DataChangeEvent.DATA_CHANGE,handleDataChange,false,0,true);
  741.          list.dataProvider = param1;
  742.          invalidate(InvalidationType.DATA);
  743.       }
  744.       
  745.       public function set restrict(param1:String) : void
  746.       {
  747.          if(componentInspectorSetting && param1 == "")
  748.          {
  749.             param1 = null;
  750.          }
  751.          if(!_editable)
  752.          {
  753.             return;
  754.          }
  755.          inputField.restrict = param1;
  756.       }
  757.       
  758.       protected function onTextInput(param1:Event) : void
  759.       {
  760.          param1.stopPropagation();
  761.          if(!_editable)
  762.          {
  763.             return;
  764.          }
  765.          editableValue = inputField.text;
  766.          selectedIndex = -1;
  767.          dispatchEvent(new Event(Event.CHANGE));
  768.       }
  769.       
  770.       protected function onInputFieldFocus(param1:FocusEvent) : void
  771.       {
  772.          inputField.addEventListener(ComponentEvent.ENTER,onEnter,false,0,true);
  773.          close();
  774.       }
  775.       
  776.       public function getItemAt(param1:uint) : Object
  777.       {
  778.          return list.getItemAt(param1);
  779.       }
  780.       
  781.       override protected function initializeAccessibility() : void
  782.       {
  783.          if(ComboBox.createAccessibilityImplementation != null)
  784.          {
  785.             ComboBox.createAccessibilityImplementation(this);
  786.          }
  787.       }
  788.       
  789.       protected function drawLayout() : void
  790.       {
  791.          var _loc1_:Number = NaN;
  792.          var _loc2_:Number = NaN;
  793.          _loc1_ = getStyleValue("buttonWidth") as Number;
  794.          _loc2_ = getStyleValue("textPadding") as Number;
  795.          background.setSize(width,height);
  796.          inputField.x = inputField.y = _loc2_;
  797.          inputField.setSize(width - _loc1_ - _loc2_,height - _loc2_);
  798.          list.width = !!isNaN(_dropdownWidth) ? Number(width) : Number(_dropdownWidth);
  799.          background.enabled = enabled;
  800.          background.drawNow();
  801.       }
  802.       
  803.       public function removeItem(param1:Object) : Object
  804.       {
  805.          return list.removeItem(param1);
  806.       }
  807.       
  808.       private function addCloseListener(param1:Event) : *
  809.       {
  810.          removeEventListener(Event.ENTER_FRAME,addCloseListener);
  811.          if(!isOpen)
  812.          {
  813.             return;
  814.          }
  815.          stage.addEventListener(MouseEvent.MOUSE_DOWN,onStageClick,false,0,true);
  816.       }
  817.       
  818.       public function get dataProvider() : DataProvider
  819.       {
  820.          return list.dataProvider;
  821.       }
  822.       
  823.       public function get textField() : TextInput
  824.       {
  825.          return inputField;
  826.       }
  827.       
  828.       protected function setStyles() : void
  829.       {
  830.          copyStylesToChild(background,BACKGROUND_STYLES);
  831.          copyStylesToChild(list,LIST_STYLES);
  832.       }
  833.       
  834.       public function set labelFunction(param1:Function) : void
  835.       {
  836.          list.labelFunction = param1;
  837.          invalidate(InvalidationType.DATA);
  838.       }
  839.       
  840.       protected function drawTextFormat() : void
  841.       {
  842.          var _loc1_:TextFormat = null;
  843.          _loc1_ = getStyleValue(!!_enabled ? "textFormat" : "disabledTextFormat") as TextFormat;
  844.          if(_loc1_ == null)
  845.          {
  846.             _loc1_ = new TextFormat();
  847.          }
  848.          inputField.textField.defaultTextFormat = _loc1_;
  849.          inputField.textField.setTextFormat(_loc1_);
  850.          setEmbedFonts();
  851.       }
  852.       
  853.       public function set selectedIndex(param1:int) : void
  854.       {
  855.          list.selectedIndex = param1;
  856.          highlightCell();
  857.          invalidate(InvalidationType.SELECTED);
  858.       }
  859.       
  860.       public function close() : void
  861.       {
  862.          highlightCell();
  863.          highlightedCell = -1;
  864.          if(!isOpen)
  865.          {
  866.             return;
  867.          }
  868.          dispatchEvent(new Event(Event.CLOSE));
  869.          stage.removeEventListener(MouseEvent.MOUSE_DOWN,onStageClick);
  870.          isOpen = false;
  871.          stage.removeChild(list);
  872.       }
  873.    }
  874. }
  875.